<?php
	if (!session_start()) session_start();
	if (!isset($_SESSION['kiemtradangnhapthinguyet']) || $_SESSION['kiemtradangnhapthinguyet']!=1) {
		header('location: ../../../index.php');
		die();
	}
	$table = "nhac";
	if(isset($_POST['ok']))
	{
		$field = 'ten_vi,ten_en,url,url_img,file,vitri,anhien,ngay,thutu';
		
		$now = getdate();
		$ngay = $now["year"]."-".$now["mon"]."-".$now["mday"]." ".$now["hours"].":".$now["minutes"].":".$now["seconds"];
		
		$values= format($_POST['ten_vi'],1);
		$values.= format($_POST["ten_en"],1);
		$values.= format($_POST["url"],1);
		$values.= format($_POST["url_img"],1);
		$values.= format($_POST["file"],1);
		$values.= format($_POST["vitri"],1);
		$values.= format($_POST['anhien'],1);
		$values.= format($ngay,1);
		$values.= format($qt->get_thutu($table),0);
		$res=$qt->insertObject($table,$field,$values);
		
		if($res){
			echo "<script>alert('Thêm dữ liệu thành công !!!');history.go(-1);</script>";
		}
	}
	
?>			
<script type="text/javascript">
function isTest() {
	if (document.getElementById("ten_vi").value=="") {
		alert("You have not entered enough information.");
		return false;
	}
	if (document.getElementById("ten_en").value=="") {
		alert("You have not entered enough information.");
		return false;
	}
	
    return true;
}	
</script>	
            	<div class="dangnhap_title">
                <a href="index.php" style="color:#F8991D;" title="Trang chủ">Trang chủ</a>
                <span style="font-size:9px;">>></span> 
                Thông tin khác
                <span style="font-size:9px;">>></span> 
                <a href="index.php?p=<?php echo $table; ?>_quanly" style="color:#F8991D;">Thư viện ảnh</a>  
            	</div>
            	<form method="post" action="index.php?p=<?php echo $table; ?>_them" onSubmit="return isTest();">
                <div class="dangnhap_col">
                    <div class="dangnhap_col_title" style="font-size:22px; color:#0E6BBB; width: 90%;">
                        Vietnamese's Information
                    </div>
                </div>
                <div class="dangnhap_col">
                    <div class="dangnhap_col_title">
                        &nbsp; &nbsp; &nbsp;- Tên(*)
                    </div>
                    <div class="dangnhap_col_input">
                        <input type="text" name="ten_vi" id="ten_vi" style="width:520px; padding:0px;" />
                    </div>
                </div>
                <!--
                <div class="dangnhap_col">
                    <div class="dangnhap_col_title" style="font-size:22px; color:#0E6BBB; width: 90%;">
                        English's Information
                    </div>
                </div>
                <div class="dangnhap_col">
                    <div class="dangnhap_col_title">
                        &nbsp; &nbsp; &nbsp;- Name(*)
                    </div>
                    <div class="dangnhap_col_input">
                        <input type="text" name="ten_en" id="ten_en" style="width:520px; padding:0px;" />
                    </div>
                </div>
                -->
                <div class="dangnhap_col">
                    <div class="dangnhap_col_title" style="font-size:22px; color:#0E6BBB; width: 90%;">
                        More Information
                    </div>
                </div>
                <!--
                <div class="dangnhap_col">
                    <div class="dangnhap_col_title">
                        &nbsp; &nbsp; &nbsp;- Url:
                    </div>
                    <div class="dangnhap_col_input">
                        <input id="url" type="text" name="url" style="width:490px; padding:0px;" value="http://" />
                    </div>
                </div>
                -->
                <div class="dangnhap_col">
                    <div class="dangnhap_col_title">
                        &nbsp; &nbsp; &nbsp;- Hình ảnh minh họa:
                    </div>
                    <div class="dangnhap_col_input">
                        <input id="url_img" type="text" name="url_img" style="width:490px; padding:0px;" />
                    	<input onclick="BrowseServer('Files:/','url_img')" type="button" name="btnChonFile" id="btnChonFile" value="...." />
                    </div>
                </div>
                <div class="dangnhap_col">
                    <div class="dangnhap_col_title">
                        &nbsp; &nbsp; &nbsp;- File:
                    </div>
                    <div class="dangnhap_col_input">
                        <input id="file" type="text" name="file" style="width:490px; padding:0px;" />
                    	<input onclick="BrowseServer('Files:/','file')" type="button" name="btnChonFile" id="btnChonFile" value="...." />
                    </div>
                </div>
                <!--
                <div class="dangnhap_col">
                    <div class="dangnhap_col_title">
                        &nbsp; &nbsp; &nbsp;- Vị trí:
                    </div>
                    <div class="dangnhap_col_input">
                        <select id="vitri" name="vitri">
                            <option value="3" >Image-left</option>
                       		<option value="2" >Image-right</option>
                            <option value="1" >Quảng cáo flash banner</option>
                            <option value="0" >Phong thủy sim</option>
                        </select>
                    </div>
                </div>
                -->
                <div class="dangnhap_col">
                    <div class="dangnhap_col_title">
                        &nbsp; &nbsp; &nbsp;- Hidden or Show:
                    </div>
                    <div class="dangnhap_col_input">
                        <input type="radio" name="anhien" value="1" checked="checked" />Show
                     	<input type="radio" name="anhien" value="0" />Hidden
                    </div>
                </div>
                <div class="dangnhap_col">
                    <div class="dangnhap_col_input">
                        <input type="submit" class="ok" border="0" name="ok" id="ok" value="" />
                        <a href="javascript:history.go(-1);"><img src="imgs/exit_button.png" border="0" /></a>
                    </div>
                </div>
               	</form>